import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/case_order_info_entity.dart';

CaseOrderInfoEntity $CaseOrderInfoEntityFromJson(Map<String, dynamic> json) {
  final CaseOrderInfoEntity caseOrderInfoEntity = CaseOrderInfoEntity();
  final List<LegalPerson>? caseClientList = (json['caseClientList'] as List<
      dynamic>?)?.map(
          (e) => jsonConvert.convert<LegalPerson>(e) as LegalPerson).toList();
  if (caseClientList != null) {
    caseOrderInfoEntity.caseClientList = caseClientList;
  }
  final List<LegalPerson>? caseOppositeList = (json['caseOppositeList'] as List<
      dynamic>?)?.map(
          (e) => jsonConvert.convert<LegalPerson>(e) as LegalPerson).toList();
  if (caseOppositeList != null) {
    caseOrderInfoEntity.caseOppositeList = caseOppositeList;
  }
  final List<LegalPerson>? caseThirdList = (json['caseThirdList'] as List<
      dynamic>?)?.map(
          (e) => jsonConvert.convert<LegalPerson>(e) as LegalPerson).toList();
  if (caseThirdList != null) {
    caseOrderInfoEntity.caseThirdList = caseThirdList;
  }
  return caseOrderInfoEntity;
}

Map<String, dynamic> $CaseOrderInfoEntityToJson(CaseOrderInfoEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['caseClientList'] =
      entity.caseClientList?.map((v) => v.toJson()).toList();
  data['caseOppositeList'] =
      entity.caseOppositeList?.map((v) => v.toJson()).toList();
  data['caseThirdList'] = entity.caseThirdList?.map((v) => v.toJson()).toList();
  return data;
}

extension CaseOrderInfoEntityExtension on CaseOrderInfoEntity {
  CaseOrderInfoEntity copyWith({
    List<LegalPerson>? caseClientList,
    List<LegalPerson>? caseOppositeList,
    List<LegalPerson>? caseThirdList,
  }) {
    return CaseOrderInfoEntity()
      ..caseClientList = caseClientList ?? this.caseClientList
      ..caseOppositeList = caseOppositeList ?? this.caseOppositeList
      ..caseThirdList = caseThirdList ?? this.caseThirdList;
  }
}

LegalPerson $LegalPersonFromJson(Map<String, dynamic> json) {
  final LegalPerson legalPerson = LegalPerson();
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    legalPerson.name = name;
  }
  final String? code = jsonConvert.convert<String>(json['code']);
  if (code != null) {
    legalPerson.code = code;
  }
  return legalPerson;
}

Map<String, dynamic> $LegalPersonToJson(LegalPerson entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['name'] = entity.name;
  data['code'] = entity.code;
  return data;
}

extension LegalPersonExtension on LegalPerson {
  LegalPerson copyWith({
    String? name,
    String? code,
  }) {
    return LegalPerson()
      ..name = name ?? this.name
      ..code = code ?? this.code;
  }
}